package com.wejoy.video.middle.station.data.enums.file;

import org.apache.commons.lang3.StringUtils;

/**
 * 上传枚举，写名每个上传的作用
 * 1.规定文件夹
 * 2.规定后缀，避免任意文件上传
 *
 * @author admin
 */
public enum EnumUpload {
    RES_PHOTO_LIB("resPhotoLib", "jpg", "多媒体资源库上传图片"),
    RES_VIDEO_LIB("resVideoLib", "mp4", "多媒体资源库上传视频"),
    QR_CODE("qrCode", "jpg", "二维码"),
    ORDER_IMG("orderImg", "jpg", "工单上传图片"),
    ORDER_VIDEO("orderVideo", "mp4", "工单上传视频"),
    ;

    EnumUpload(String baseDir, String suffix, String desc) {
        this.baseDir = baseDir;
        this.suffix = suffix;
        this.desc = desc;
    }

    /**
     * 上传具体业务目录,只允许为英文数字，不允许重复
     * 业务名称，请参考业务表名称也定义
     */
    String baseDir;
    /**
     * 文件类型，比如jpg，png，txt，apk等等
     */
    String suffix;
    /**
     * 功能描述说明
     */
    String desc;

    public static EnumUpload getEnum(String baseDir) {
        if (StringUtils.isEmpty(baseDir)) {
            return null;
        }
        for (EnumUpload type : EnumUpload.values()) {
            if (type.getBaseDir().equals(baseDir)) {
                return type;
            }
        }
        return null;
    }

    public String getBaseDir() {
        return baseDir;
    }

    public void setBaseDir(String baseDir) {
        this.baseDir = baseDir;
    }

    public String getSuffix() {
        return suffix;
    }

    public void setSuffix(String suffix) {
        this.suffix = suffix;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
